import re

# re.findall(r'\d+', big_page)[0]
# re.search()
# 1- .	匹配任意1个字符（除了\n）
result = re.match('.', 'a')
print(result.group())

re1 = re.match('wha.', 'what')
print(re1.group())

re2 = re.match('h.w', 'how')
print(re2.group())

# res2.group() 匹配不到会报错 AttributeError: 'NoneType' object has no attribute 'group'

# 2- [ ]	匹配[ ]中列举的字符
#
re3 = re.match('h', 'hello china')
print(re3.group())

re4 = re.match('H', 'Hello Python')
print(re4.group())

# 匹配开头是大小写都OK
re5 = re.match('[hH]', 'hello china')
print(re5.group())

re6 = re.match('[hH]', 'Hello china')
print(re6.group())

# 匹配开头 [0-9] [0123456789] \d
re7 = re.match('[0-9]', '0-python')
print(re7.group())

re8 = re.match("[0-35-9]Hello Python", "4Hello Python")
# print(re8.group())

# 3- \d	匹配数字，即 0-9
re9 = re.match('\d', '1javascript:topage(11)')
print(re9.group())

# 4- \D	匹配非数字，即不是数字
re10 = re.match('\D', 'javascript:topage(11)')
print(re10.group())

# 5- \s	匹配空白，即 空格，tab键
re11 = re.match('\s', ' aa ')
print(re11.group())

re11 = re.match('\s', '    aa ')
print(re11.group())

# 6- \S	匹配非空白
re11 = re.match('\S', 'aa ')
print(re11.group())

# 7- \w	匹配非特殊字符，即a-z、A-Z、0-9、_、汉字
data = ['123', 'abc', 'ABC', '中国']
for i in data:
    re12 = re.match('\w', i)
    print(re12.group())

# 8- \W	匹配特殊字符，即非字母、非数字、非汉字
data = ['!@@', '^^', '**', '&&']
for i in data:
    re12 = re.match('\W', i)
    print(re12.group())



